#include "result.h"

Result::Result(bool suc, string message)
{
    success = suc;
    msg = message;
}

Result::Result(bool succ){
    success=succ;
    msg=" ";
}

void Result::setMessage(string s){
    msg = s;
}

Result Result::operator &&(Result r){
    return Result(success&&r.getResult(), msg.append(r.getMessage()));
}

Result& Result::operator &=(Result r){
    string s = "\n";
    success &= r.getResult();
    msg = msg.append(s.append(r.getMessage()));
    return *this;
}

 Result& Result::andRes (Result r, bool takesSecondMsg) {
    success &= r.getResult();
    if (takesSecondMsg || !r.getResult() || msg.compare("")==0) {
        msg = r.getMessage();
    }
    else if (!success && !r.getResult()) {
        msg = msg.append(", ").append(r.getMessage());
    }
    return *this;
}

Result& Result::andBool(bool a){
    success &= a;
    return *this;
}

bool Result::getResult()
{
    return success;
}

string Result::getMessage()
{
    return msg;
}

const char *Result::getMessageCStr()
{
    return msg.c_str();
}


